package com.itheima.mapper;

import com.itheima.common.dto.OrderUpdateDto;
import com.itheima.pojo.Order;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.List;

/**
 * @className OrderMapper
 */
@Mapper
public interface OrderMapper {
    List<Order> selectOrderByPage(String queryString); //分页查询

    @Update("update t_order set orderStatus = #{orderStatus} where id = #{id}")
    void updateOrderStatus(OrderUpdateDto orderUpdateDto); //修改预约状态

    @Select("select count(*) from t_order where orderDate between #{begin} and #{end}")
    Integer countOrders(@Param("begin") LocalDate begin, @Param("end") LocalDate end); //统计预约数

    @Select("select count(*) from t_order where orderStatus = '已到访' and orderDate between #{begin} and #{end}")
    Integer countVisits(@Param("begin") LocalDate begin, @Param("end") LocalDate end); //统计到访数
}
